<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%--
  Created by IntelliJ IDEA.
  User: wzs
  Date: 2017/7/15
  Time: 15:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>${title}</title>
    <link href="/css/site.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="/js/jquery-1.10.2.js"></script>
</head>
<body>
<div class="container">
    <h2>${title}</h2>
    <div><a href="/user/add" title="新增" target="_blank">新增用户</a></div>
    <table cellpadding="0" cellspacing="0" class="gridtable">
        <tr>
            <th>用户名</th>
            <th>昵称</th>
            <th>最近登录时间</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${users}" var="user">
            <tr>
                <td>${user.username}</td>
                <td>${user.nickname}</td>
                <td><fmt:formatDate value="${user.lastlogintime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>
                    <a href="/user/detail/${user.uid}" target="_blank">ViewDetail</a>
                    <a href="javascript:;" class="a_remove" data-id="${user.uid}" target="_blank" title="删除">删除</a>
                </td>
            </tr>
        </c:forEach>

    </table>
</div>
<script>
    $(function () {
        $(".a_remove").click(function () {
            if (confirm("确定要删除吗？")){
                $.post("/user/remove/"+$(this).data("id"),{},function (data) {
                    if (data.status==200){
                        alert("删除成功");
                        window.location.href=window.location.href;
                    }
                    else{
                        alert(data.msg);
                    }

                });
            }

        });
    })
</script>
</body>
</html>
